package basicGUI;

import javax.swing.JPanel;
import javax.swing.JList;

import java.awt.GridLayout;

import javax.swing.JButton;

import main.ChatGUI;
import model.User;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ConnectedVIew extends BasicMainView {

	/**
	 * Create the panel.
	 */
	public ConnectedVIew(ChatGUI gui) {
		super(gui);
		
		final JList<User> userslist = new JList<User>(gui.getController().getModel().getConnectedUsers());
		userslist.setBounds(0, 0, 225, 300);
		userslist.setVisible(true);
		setLayout(null);
		add(userslist);
		
		JButton btnStartConversation = new JButton("Start Conversation");
		btnStartConversation.setBounds(225, 206, 225, 94);
		btnStartConversation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				getGui().getController().getCurrentState().openNewChatWindow(userslist.getSelectedValue());
			}
		});
		add(btnStartConversation);
		
		JButton btnDisconnect = new JButton("Disconnect");
		btnDisconnect.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getGui().getController().getCurrentState().disconnect();

			}
		});
		btnDisconnect.setBounds(225, 113, 225, 94);
		add(btnDisconnect);

	}

	
}
